import { getNotesRequest } from "@/apis/notes"
import { makeAutoObservable } from "mobx"
import { makePersistable } from "mobx-persist-store"

export interface notesType {
	id: number
	outTime: string
	inTime: string
	number: string
	picture: string
	cost: number
	cid: number
	notes: string //车位类型
}
export class notesStore {
	notes: notesType[] = []
	constructor() {
		makeAutoObservable(this, {}, { autoBind: true })
		makePersistable(this, {
			name: 'notesStore',
			properties: ['notes'],
			storage: window.localStorage,
		})
	}

	setNotes(notes: notesType[]) {
		this.notes = notes
	}

	getNotes() {
		getNotesRequest().then((res: any) => {
			this.setNotes(res.result)
		})
	}
}
